import 'package:banyou_app/app/config/colors.dart';
import 'package:banyou_app/app/widget/load_network_image_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../controllers/mine_controller.dart';

class MineView extends GetView<MineController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          Positioned.fill(
              child: Image.asset(
            'assets/images/mine_gb.png',
            width: 1.sw,
            height: 1.sh,
            fit: BoxFit.cover,
          )),
          Positioned(
            top: 0,
            bottom: 0,
            left: 16,
            right: 16,
            child: SafeArea(
              child: Column(
                children: [
                  SizedBox(height: 92.h),
                  Row(
                    children: [
                      Obx(() => controller.mobile.value == '165****5975'
                          ? ClipOval(
                              child: LoadNetworkImageWidget(
                                  width: 74.w,
                                  height: 74.w,
                                  fit: BoxFit.cover,
                                  imageUrl:
                                      'https://aqcdn.olbibo.com.cn/Qa/1aa68c75c4a77c87f97fb686b2f068676.png'),
                            )
                          : Container(
                              decoration: const BoxDecoration(
                                color: ColorConfig.white,
                                shape: BoxShape.circle,
                                boxShadow: [
                                  BoxShadow(
                                    color: Color(0xFFE8E8E8),
                                    offset: Offset(8, 8),
                                    blurRadius: 10,
                                    spreadRadius: 1,
                                  ),
                                ],
                              ),
                              padding: EdgeInsets.all(10),
                              child: ClipOval(
                                child: Image.asset('assets/images/touxiang.png',
                                    width: 74.w,
                                    height: 74.w,
                                    fit: BoxFit.cover),
                              ),
                            )),
                      SizedBox(width: 20),
                      Obx(() => Text(
                            controller.mobile.value,
                            style: TextStyle(
                                fontSize: 24.sp,
                                fontWeight: FontWeight.bold,
                                color: ColorConfig.text_label),
                          )),
                      // Column(
                      //   mainAxisAlignment: MainAxisAlignment.start,
                      //   crossAxisAlignment: CrossAxisAlignment.start,
                      //   children: [

                      // SizedBox(height: 10),
                      // InkWell(
                      //   onTap: controller.toInfo,
                      //   child: Container(
                      //     padding: EdgeInsets.symmetric(
                      //         horizontal: 12, vertical: 3),
                      //     decoration: BoxDecoration(
                      //       color: ColorConfig.white,
                      //       border: Border.all(color: Color(0x61959595)),
                      //       borderRadius:
                      //           BorderRadius.all(Radius.circular(15)),
                      //     ),
                      // child: Row(
                      //   children: [
                      //     Text(
                      //       '修改资料',
                      //       style: TextStyle(
                      //           fontSize: 14.sp,
                      //           color: Color(0xFF959595)),
                      //     ),
                      //     SizedBox(width: 10),
                      //     Image.asset('assets/images/组 20@2x.png',
                      //         width: 12, height: 12)
                      //   ],
                      // ),
                      //   ),
                      // )
                      // ],
                      // )
                    ],
                  ),
                  SizedBox(height: 43),
                  Container(
                    width: 1.sw,
                    padding: EdgeInsets.symmetric(horizontal: 18, vertical: 20),
                    decoration: BoxDecoration(
                      color: ColorConfig.white,
                      borderRadius: BorderRadius.all(Radius.circular(15)),
                    ),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '常用功能',
                          style: TextStyle(
                              fontSize: 18.sp,
                              fontWeight: FontWeight.bold,
                              color: ColorConfig.text_label),
                        ),
                        SizedBox(height: 15),
                        Row(
                          children: [
                            itemWidget('assets/images/组 28@2x.png', '我的动态', 0),
                            SizedBox(width: 30),
                            itemWidget('assets/images/组 31@2x.png', '客服', 1),
                            SizedBox(width: 30),
                            itemWidget('assets/images/组 37@2x.png', '退出登录', 2),
                            SizedBox(width: 30),
                            itemWidget('assets/images/组 36@2x.png', '注销账户', 3),
                          ],
                        ),
                        SizedBox(height: 20),
                        Row(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            itemWidget('assets/images/组 33@2x.png', '隐私协议', 4),
                            SizedBox(width: 90),
                            // Expanded(flex: 3, child: Container())
                          ],
                        ),
                      ],
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget itemWidget(String img, String title, int type) {
    return InkWell(
      onTap: () {
        controller.clickItem(type);
      },
      child: Column(
        children: [
          Image.asset(img, width: 47.w, fit: BoxFit.fill),
          SizedBox(height: 2),
          Text(
            title,
            style: TextStyle(
                fontSize: 14.sp,
                fontWeight: FontWeight.bold,
                color: ColorConfig.text_label),
          ),
        ],
      ),
    );
  }
}
